package com.train.mgr.config.secrity.components;

import com.train.mgr.modules.system.entity.User;
import com.train.mgr.modules.system.service.MenuService;
import com.train.mgr.modules.system.service.UserService;
import io.swagger.models.auth.In;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * 用户登录信息查询Service
 *
 * @author cxg
 * @since 2023-03-25 19:55:38
 */
@Slf4j
@Component
public class UserDetailsServiceImpl extends AbstractUserDetailsService {

    private final UserService userService;

    public UserDetailsServiceImpl( UserService userService) {
      //  super(menuService);
        this.userService = userService;
    }

    @Override
    public User findUser(String principal) {
        return userService.getByUsername(null, principal);
    }

    public User loginByWechat(String openId, Integer userType) {
        return userService.getByOpenIdUserType(openId, userType);
    }

    public User loginByUserNamePassword(String username, String password, Integer userType) {
        return userService.getByUserNamePassword(username, password, userType);
    }
}
